<?php
include '../lib/BLL/DonViBLL.php';
include '../lib/BLL/DmNganhBLL.php';
include '../lib/BLL/DmMonHocBLL.php';
include '../lib/BLL/DonViHocVuBLL.php';
//include('db.php');
	//$db = new db_mysql();
	//$db->connect($host,$name,$pass,$database);
$dv = new DonViBLL();
$nganh = new DmNganhBLL();
$mh = new DmMonHocBLL();
$dvhv = new DonViHocVuBLL();

$ds_nganh = $nganh->getListNganh();
$ds_dv = $dv->getListDonVi_Lienket();
$ds_mh = $mh->getListDmMonHoc();
$ds_dvhv = $dvhv->getListDonViHocVu();

//$mdv = $ds_dv->getma_donvi();
//$mhv = $dvhv->getma_donvihocvu();
//$mn = $nganh->getmadm_nganh();
//$mahoidong = $db->getOneField("SELECT ma_hoidong FROM tbl_hoidongthi WHERE ma_donvihocvu = '1-2013' AND ma_donvi = '01'");
//$tenhoidong = $db->getOneField("SELECT ten_donvi FROM tbl_donvi WHERE ma_donvi = '01'");
$sql = "SELECT dst.ma_dsthi, dv.ten_donvi, dmn.ten_nganh, mh.ten_mh, dst.ngaythi, ch.khungthoigian,ten_tt_diemthi,ttdt.madm_tt_diemthi FROM tbl_dsthi AS dst
										INNER JOIN dm_cahoc AS ch ON ch.madm_ca = dst.madm_ca
										INNER JOIN tbl_mon_ctdt AS mctdt ON dst.ma_mon_ctdt = mctdt.ma_mon_ctdt
										INNER JOIN dm_monhoc AS mh ON mh.madm_mh = mctdt.ma_monhoc
										INNER JOIN tbl_ctdt AS ctdt ON ctdt.ma_ctdt = mctdt.ma_ctdt
										INNER JOIN dm_nganh AS dmn ON dmn.madm_nganh = ctdt.madm_nganh
										INNER JOIN tbl_hoidongthi AS hd on hd.ma_hoidong = dst.ma_hoidongthi
										INNER JOIN tbl_donvi AS dv ON hd.ma_donvi = dv.ma_donvi
                                        INNER JOIN dm_trangthai_diemthi AS ttdt ON ttdt.madm_tt_diemthi=dst.trangthai_dsthi
										";
			//WHERE dst.ma_hoidongthi = '$mahoidong' AND dmn.madm_nganh = '41' AND mh.madm_mh = '19'
$listdsthi = $db->getList($sql);

$smarty->assign('listdst', $listdsthi);
//$smarty->assign('tenhd', $tenhoidong);
$smarty->assign('ds_mh',$ds_mh);
$smarty->assign('ds_dv',$ds_dv);
$smarty->assign('ds_nganh',$ds_nganh);
$smarty->assign('ds_dvhv',$ds_dvhv);

$smarty->display('tochucthi/lapdsthi_filter.tpl');
?>